package com.jusda.message.entity;

import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import org.springframework.util.Assert;

import java.util.ArrayList;
import java.util.List;

/**
 * @Author yiyi
 * @Date 2022/3/14-上午10:54
 * @Description:
 */

@AllArgsConstructor
@NoArgsConstructor
@Data
public class UserScore {

    private Long id;

    private String username;


    private UserScoreLevelEnum scoreLevel;

    public UserScore(String username, UserScoreLevelEnum scoreLevel) {
        this.username = username;
        this.scoreLevel = scoreLevel;
    }

    public static List<UserScore> batchGenerate(int createSize) {
        StringBuilder username = new StringBuilder();
        List<UserScore> batchCreateList = new ArrayList<UserScore>();
        Assert.isTrue(createSize > 0, "创建对象的数量错误!" + createSize);
        for (int i = 0; i < createSize; i++) {
            username.setLength(0);
            username.append("username").append(i);
            batchCreateList.add(new UserScore(username.toString(), (i * 13 % 4 == 0 ? UserScoreLevelEnum.EXCELLENT: UserScoreLevelEnum.BAD)));
        }
        return batchCreateList;
    }
}
